
const TokenKey = 'admin_user_token'
const TokenExpirekey = 'admin_user_token_expire'

// 获取token
export function getToken(){
    let token = localStorage.getItem(TokenKey)
    if(!token){
        //判断是否超时
        let expire = localStorage.getItem(TokenExpirekey)
        if(expire < new Date().getTime()){
            removeToken()
            token = null
        }
    }
    return token
}

// 设置token
export function setToken(token){
    localStorage.setItem(TokenKey, token)
    localStorage.setItem(TokenExpirekey, new Date().getTime() + 1000 * 60 * 60 )
}

// 删除token
export function removeToken(){
    localStorage.removeItem(TokenKey)
    localStorage.removeItem(TokenExpirekey)
}


